/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include "gl_lib_include.h"
#include "gl_smmp_func.h"
#include "gl_smmp_funcbasicconf.h"
#include "gl_smmp_funcspam.h"
#include "gl_smmp_funcuser.h"
#include "gl_smmp_response.h"
#include "gl_mail_define.h"
#include "gl_mail_log.h"
#include "gl_mail_usercheck.h"
#include "gl_mail_user.h"
#include "gl_mail_config.h"
#include "gl_mail_statistics.h"




void GlSmmpFuncViewStream(glsmmpsession_ *gsn, char *szVal)
{
	int i;
	int n;

	GlStatStreamTimeCheck();

	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "+OK Socket stream statistics (recv : send bytes/min while 1 hour)");
	for (i=0, n=glData.iStatTime; i<60; i++, n--)
	{
		if (n < 0)
			n = 59;		
		GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "%s%.2dmin : %12d %12d", 
			i?"-":" ", i, glData.iStatRecv[n], glData.iStatSend[n]);
	}
}


void GlSmmpFuncViewThread(glsmmpsession_ *gsn, char *szVal)
{
	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "+OK Thread monitor (running/total thread, min~max)");
	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "SMTP : %d/%d, %d~%d", glData.thSmtp.iRunning, glData.thSmtp.iCount, glData.thSmtp.iMin, glData.thSmtp.iMax);
	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "POP3 : %d/%d, %d~%d", glData.thPop3.iRunning, glData.thPop3.iCount, glData.thPop3.iMin, glData.thPop3.iMax);
	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "MTA  : %d/%d, %d~%d", glData.thMta.iRunning,  glData.thMta.iCount,  glData.thMta.iMin, glData.thMta.iMax);
	GlSocketStreamPrintfLnLog(gsn->stream, GlLogSmmp, "SMMP : %d/%d, %d~%d", glData.thSmmp.iRunning, glData.thSmmp.iCount, glData.thSmmp.iMin, glData.thSmmp.iMax);
}
